/*
package com.park.platform.service.impl;

import com.park.common.bean.PageBean;
import com.park.common.constant.IDBConstant;
import com.park.common.constant.IPlatformConstant;
import com.park.common.exception.MessageException;
import com.park.common.util.StrUtil;
import com.park.platform.dao.IBaseDao;
import com.park.platform.service.ICmsService;
import com.park.platform.service.IDictService;
import org.apache.commons.httpclient.util.DateUtil;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;

*/
/**
 * Created by Administrator on 2016/9/8.
 *//*

@Service
public class CmsServiceImpl extends BaseService implements ICmsService {

    @Autowired
    private IBaseDao baseDao;

    @Autowired
    private IDictService dictService;

    @Autowired
    private ICmsResourceService cmsResourceService;

    @Autowired
    private FileUploader fileUploader;

    @Autowired
    private IStaticPageSvc staticPageSvc;

    @Override
    public void saveArticle(Article article, MultipartFile multipartFile){
        Date date = new Date();
        if(article.getArticleId() == null) {
            article.setCreatedAt(date);
            article.setPublishAt(date);
        }else{
            Article articleDB = getArticle(article.getArticleId());

            article.setCreatedAt(articleDB.getCreatedAt());
            article.setPublishAt(articleDB.getPublishAt());
        }
        if(IDBConstant.LOGIC_STATUS_NO.equals(article.getPostStatus()) && IDBConstant.LOGIC_STATUS_YES.equals(article.getPublishStatus())) throw new MessageException("请先通过审核，再进行发布！");
        if(IDBConstant.LOGIC_STATUS_YES.equals(article.getPublishStatus())) article.setPublishAt(date);

        baseDao.save(article, article.getArticleId());

        if(multipartFile != null){

            cmsResourceService.delete(article.getArticleId(), IDBConstant.RESOURCE_SERVICE_TYPE_CMS_ARTICLE);
            ////////////////////////////
            CmsResource resource = cmsResourceService.saveCmsResource(multipartFile, article.getArticleId(), IDBConstant.RESOURCE_SERVICE_TYPE_CMS_ARTICLE, IDBConstant.RESOURCE_TYPE_THUMBNAIL, fileUploader.getCmsImagesFilePath());

            try {
                fileUploader.saveToRootDisc(multipartFile.getInputStream(), fileUploader.getCmsImagesFilePath(), resource.getResourceName());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        try {
            //写文档到页面
            staticPageSvc.html(article.getBody(), fileUploader.getCmsFilePath() + "/" + article.getArticleId() + IPlatformConstant.CMS_FILE_EXTENSION, null, null, null);
        }catch(Exception ex){
            ex.printStackTrace();
        }
    }

    @Override
    public PageBean getArticleList(CmsInputView cmsInputView){

        Integer channelId = cmsInputView.getChannelId();
        String postStatus = cmsInputView.getPostStatus();
        String publishStatus = cmsInputView.getPublishStatus();
        String listingDisplay = cmsInputView.getListingDisplay();
        String title = cmsInputView.getTitle();

        StringBuilder headSql = new StringBuilder("SELECT a.*, b.channelName ");
        StringBuilder bodySql = new StringBuilder(" FROM article a, channel b WHERE a.channelId=b.channelId");
        if(channelId != null && channelId.intValue() > 0){
            bodySql.append(" AND a.channelId = :channelId");
        }
        if(StringUtils.isNotBlank(postStatus)){
            bodySql.append(" AND a.postStatus = :postStatus");
        }
        if(StringUtils.isNotBlank(publishStatus)){
            bodySql.append(" AND a.publishStatus = :publishStatus");
        }
        if(StringUtils.isNotBlank(title)){
            bodySql.append(" AND a.title LIKE :title");
            cmsInputView.setTitle("%" + cmsInputView.getTitle() + "%");
        }
        if(StringUtils.isNotBlank(listingDisplay)){
            bodySql.append(" AND b.listingDisplay = :listingDisplay");
        }
        bodySql.append(" ORDER BY a.sticky,a.publishAt DESC");

        PageBean pageBean = super.getPageBean(headSql, bodySql, null, cmsInputView);

        pageBean.setList(getType(pageBean.getList()));

        cmsInputView.setTitle(title);

        return pageBean;
    }

    @Override
    public Map<String, Object> getArticleDetails(int articleId){
        return baseDao.queryBySqlFirst("SELECT * FROM article WHERE articleId = ?",  articleId);
    }

    @Override
    public void updateArticleReadNumber(int articleId) {
        baseDao.updateBySql("UPDATE article SET readNumber=readNumber+1 WHERE articleId=?", articleId);
    }

    @Override
    public Article getArticle(int articleId){
        return baseDao.getToEvict(Article.class, articleId);
    }

    @Override
    public void deleteArticle(int articleId){
        baseDao.delete(getArticle(articleId));
    }

    private List<Map<String, Object>> getType(List<Map<String, Object>> list){
        for(Map<String, Object> map : list) {
            getType(map);
        }
        return list;
    }

}
*/
